package com.tn.po.server;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.tn.bo.UserProfile;
import com.tn.dao.UserDAO;

public class RegisterServlet extends HttpServlet {
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)	throws IOException, ServletException {
		UserDAO uDao = new UserDAO();
		String regHash = request.getQueryString();
		String userId = uDao.findUserRegMapping(regHash);
		HttpSession session = request.getSession(true);
		UserProfile userProfile = uDao.getUserProfile(Long.parseLong(userId));
		session.setAttribute("userProfile", userProfile);
		
	    //logic to put user verified to true.
		String destination = "/jsp/companyRegister.jsp";
		RequestDispatcher rd = getServletContext().getRequestDispatcher(
				destination);
		rd.forward(request, response);
		
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)

	throws IOException, ServletException {
		
		doGet(request,response);
	}
}
